pointer and malloc [closed]

Posted by gcc on Stack Overflow See other posts from Stack Overflow or by gcc
Published on 2010-05-05T21:51:52Z Indexed on 2010/05/05 21:58 UTC
Read the original article Hit count: 135

Filed under:

How many methods/ways are there taking input by using with pointer and dynamic memory?

Input:

3 1 2 n k l 2 1 2 p 4 55 62 * # x

(x is stop value, first input always integer)

Example code:

p=malloc(sizeof(int));
scanf("%d",&num_arrays);
while(1)
{
    scanf("%c",&(*(p+i)));
    if(*(p+i)=='x')
        break;
    ++i;
}

"3" is stored in num_arrays. The other input values are stored in pointer[array].

© Stack Overflow or respective owner

Related posts about c